import redis.clients.jedis.Jedis;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @author 徒有琴
 */
public class RedisClient {
    public static void main(String[] args) {
        Socket socket = null;
        OutputStream output = null;
        InputStream input = null;
        try {
            socket = new Socket("192.168.13.85", 6380);
            output = socket.getOutputStream();
            output.write(("*4\r\n$4\r\nhset\r\n$3\r\nstu\r\n$4\r\nname\r\n$9\r\nlvyongtao\r\n"
                    + "*3\r\n$3\r\nset\r\n$2\r\naa\r\n$1\r\nb\r\n").getBytes());
            output.flush();
            input = socket.getInputStream();
            byte[] arr = new byte[1024];
            int len = input.read(arr);
            String message = new String(arr, 0, len);
            System.out.println(message);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                input.close();
                output.close();
                socket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
